<%--
  Created by IntelliJ IDEA.
  User: dell
  Date: 2021/10/5
  Time: 13:47
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head lang="en">
    <title>Title</title>
    <script src="${pageContext.request.contextPath}/js/jquery-3.3.1.min.js"></script>
    <script src="${pageContext.request.contextPath}/js/jquery.md5.js"></script>
    <link href="${pageContext.request.contextPath}/css/customer/register.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/css/common.css" rel="stylesheet">
</head>
<body>
<%--<div class="fail">${addMessage}</div>--%>
<div class="login-img">
    <div class="w1180">
        <div class="login">
            <div class="login-left">
                <img src="${pageContext.request.contextPath}/images/login-left.jpg">
                <div class="login-left-text">
                    <div class="login-left-top">
                        <span></span>
                        "注册即享好礼"
                        <span></span>
                    </div>
                    <ul class="login-left-logo">
                        <li>
                            <span class="icon">减</span>
                            <p>登录就送优惠卷</p>
                        </li>
                        <li>
                            <span class="icon">￥</span>
                            <p>优惠满减满足你</p>
                        </li>
                    </ul>
                </div>
            </div>
            <div class="register-right">
                <form class="registForm" method="post">
                    <div class="register-right-top">
                        <h3>新用户注册</h3>
                    </div>
                    <div class="register-right-top1">
                        <ul class="register-right-main">
                            <li>
                                <input name="custTel" class="username" type="text" placeholder="请输入你的手机号" maxlength="11">
                                <span class="username-msg"></span>
                            </li>
                            <li>
                                <input type="text" placeholder="请输入验证码">
                                <input class="verification" value="获得验证码" readonly>
                            </li>
                            <li>
                                <input name="custPassword" class="register-password" type="password" placeholder="请输入密码" max="18">
                                <span class="register-password-msg"></span>
                            </li>
                            <li>
                                <input class="register-password2" type="password" placeholder="再次确认密码" max="18">
                                <span class="register-password-msg2"></span>
                            </li>
                        </ul>

                        <div class="register-right-text">
                            <p><input type="checkbox">
                                我已阅读并同意
                                <a href="">《小橘租车会员注册协议》</a>和
                                <a href=""> 《小橘租车隐私政策》</a>
                            </p>
                        </div>
                        <div class="register-right-btn">
                            <input  type="submit" value="注册" class="register-btn-popup">

                            <!--                    <a href="" title="注册" class="register-btn-popup">注册</a>-->
                        </div>
                        <div class="register-last">
                            已有帐号,
                            <a href="${pageContext.request.contextPath}/customer/login.jsp">立即登录</a>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script src="${pageContext.request.contextPath}/js/customer/register.js"></script>
<script>
    $(".register-btn-popup").click(function () {
        var salt = "springbootdemo";
        var newPassword = $.md5($(".register-password").val()+ salt);
        $(".register-password").val(newPassword);
        var data = $(".registForm").serialize();
        console.log("data:"+data);

        $.post("${pageContext.request.contextPath}/register",
            data,
            function (result) {
            if(result.code==200){
                window.location.href="${pageContext.request.contextPath}/customer/login"
            }else {
                window.location.href="${pageContext.request.contextPath}/customer/register"
            }

            console.log("测试"+result)
            },
            "json"
        );
    })
</script>
</body>
</html>
